Skip to content

feat: implement automatic chunking for FileCreate and FileUpdate#2806

Open
Didzapp-Dave wants to merge 10 commits into
hiero-ledger:mainfrom
Didzapp-Dave:Refactor_FileCreate_FileUpdate_and_FileAppend
Open

feat: implement automatic chunking for FileCreate and FileUpdate#2806
Didzapp-Dave wants to merge 10 commits into
hiero-ledger:mainfrom
Didzapp-Dave:Refactor_FileCreate_FileUpdate_and_FileAppend

Conversation

@Didzapp-Dave

@Didzapp-Dave Didzapp-Dave commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description:

This PR implements automatic chunking for FileCreateTransaction and FileUpdateTransaction, bringing them into parity with FileAppendTransaction.

Currently, FileCreate and FileUpdate are limited to a single transaction size. By refactoring these to extend ChunkedTransaction, they can now handle large content by automatically splitting data into chunks.

Related issue(s):

Fixes #1983

Notes for reviewer:

Changes

1. Refactor
*   Inheritance: Updated FileCreateTransaction and FileUpdateTransaction to extend ChunkedTransaction instead of the base Transaction class.
*   State Management: Removed redundant local byte[] contents arrays in FileCreate and FileUpdate, migrating state management to the data field provided by ChunkedTransaction.
*   Template Pattern Implementation: Introduced a protected abstract method extractContents(TransactionBody body) in ChunkedTransaction. This allows the base class to handle the generic loop for inner-signed transactions while letting child classes specify which protobuf field to extract content from.

2. Logic Migration
*   Common Logic: Created hasInnerSignedTransactions() and setDataFromInnerSignedTransactions() from FileAppendTransaction chunking logic and moved it to ChunkedTransaction to eliminate code duplication across the three file-service transactions.
*   Chunking Callbacks: Implemented onFreezeChunk overrides in FileCreateTransaction and FileUpdateTransaction. 
*   Added missing import for TransactionID (setFileCreate and setFileUpdate)

3. API Alignment
*   Updated getContents(), setContents(byte[]), and setContents(String) in all target classes to use data field and handlers provided by ChunkedTransaction.
*   Updated initFromTransactionBody() and build() methods to use data field and handlers provided by ChunkedTransaction.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

transactions (hiero-ledger#1983)

Signed-off-by: David Campbell <davidcampbell0025@gmail.com>
transactions (hiero-ledger#1983)

Signed-off-by: David Campbell <davidcampbell0025@gmail.com>
Signed-off-by: David Campbell <davidcampbell0025@gmail.com>
Signed-off-by: David Campbell <davidcampbell0025@gmail.com>
Signed-off-by: David Campbell <davidcampbell0025@gmail.com>
Signed-off-by: David Campbell <davidcampbell0025@gmail.com>
Signed-off-by: David Campbell <davidcampbell0025@gmail.com>
@Didzapp-Dave Didzapp-Dave deleted the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 12:59
@Didzapp-Dave Didzapp-Dave restored the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 13:13
@Didzapp-Dave Didzapp-Dave deleted the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 13:16
@Didzapp-Dave Didzapp-Dave restored the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 13:18
@Didzapp-Dave Didzapp-Dave deleted the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 13:20
@Didzapp-Dave Didzapp-Dave restored the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 13:21
@Didzapp-Dave Didzapp-Dave deleted the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 13:44
@Didzapp-Dave Didzapp-Dave restored the Refactor_FileCreate_FileUpdate_and_FileAppend branch June 26, 2026 13:47
@Didzapp-Dave Didzapp-Dave reopened this Jun 26, 2026
@Didzapp-Dave

Copy link
Copy Markdown
Contributor Author

Apologies for the amount of commits, delete and restores ect ... I'm still working out the UI and how git works, i was trying to reset the branch so it looked like the work was done in one commit. I'm not sure if that creates less work for the reviewer or not , but i was unable to. Any advice you can spare on uploading PR's would be appreciated. thanks for your patience and understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileCreate/FileUpdate automatic chunking

1 participant